<template>
	<div>
		<div class="search_form">
			<div>
				<el-input v-model="searchForm.orderNo" size="mini" class="others" placeholder="订单编号" clearable></el-input>
				<el-select
					size="mini"
					clearable
					placeholder="请选择客户"
					v-model="searchForm.customerId"
					class="others"
					popper-class="selectClass"
				>
					<el-option
						v-for="(item, index) in cusList"
						:key="index"
						:label="item.customerName"
						:value="item.customerId"
					></el-option>
				</el-select>

				<el-select
						size="mini"
						clearable
						placeholder="选择树种"
						v-model="searchForm.treeSpeciesCode"
						class="others"
				>
					<el-option v-for="item in cargoList" :key="item.dictValue" :label="item.dictLabel"
							   :value="item.dictValue"></el-option>
				</el-select>


				<el-button class="search_btn" type="primary" icon="el-icon-search" size="mini" @click="searchData">查询</el-button>
				<el-button icon="el-icon-refresh-right" size="mini" @click="resetSearch">重置</el-button>
			</div>
			<div>
				<!-- <el-button size="mini" icon="el-icon-plus" @click="add" type="primary" v-hasPermi="['businessManagement:tBusDryOrder:insert']">新增</el-button>
        <el-button v-hasPermi="['businessManagement:tBusDryOrder:updat']" size="mini" icon="el-icon-s-check" type="primary" @click="auditStatus">审核</el-button> -->
                <el-button
                        class="search_btn"
                        type="primary"
                        v-hasPermi="['dryingManagement:receiptWarehousing']"
                        icon="el-icon-document"
                        size="mini"
                        @click="showConfirmed"
                >
                    入库单确认
                </el-button>
                <el-button
					class="search_btn"
					type="primary"
					v-hasPermi="['dryingManagement:storageManagement']"
					icon="el-icon-circle-plus-outline"
					size="mini"
					@click="beLaidUping"
				>
					收货
				</el-button>
				<el-button
					class="search_btn"
					type="primary"
					v-hasPermi="['dryingManagement:kilnEntryManagement']"
					icon="el-icon-circle-plus-outline"
					size="mini"
					@click="kilnEntrying"
				>
					入窑
				</el-button>
				<el-button
					class="search_btn"
					type="primary"
					v-hasPermi="['dryingManagement:kilnOutletManagement']"
					icon="el-icon-remove-outline"
					size="mini"
					@click="kilnDischarge"
				>
					出窑
				</el-button>
				<el-button
					class="search_btn"
					type="primary"
					v-hasPermi="['dryingManagement:deliveryManagement']"
					icon="el-icon-remove-outline"
					size="mini"
					@click="releaseDowning"
				>
					放货
				</el-button>
			</div>
		</div>
		<!-- 主列表table -->
		<BaseTable
			:loading="loading"
			:data="tableData"
			:columns="columns"
			:tableHeight="tableHeight"
			@details="getSelectRow"
			:pagination="queryall"
			@size-change="sizeChange"
			@current-change="pageChange"
		>
			<el-table-column fixed="right" align="center" label="操作" slot="operationColumn" width="220px">
				<template slot-scope="scope">
					<el-button
						size="mini"
						title="详情"
						v-hasPermi="['metaDataManagement:Customer:customerUpdate']"
						@click.stop="handleEdit(scope.row)"
					>
						<span style="color: #0b6cd6">
							<i class="iconfont icon-1-07"></i>
							详情
						</span>
					</el-button>
				</template>
			</el-table-column>
		</BaseTable>

		<div>
			<el-tabs v-model="activeName" type="card" @tab-click="handleClick(activeName)">
				<el-tab-pane label="入库单确认" name="first">
					<!-- 主列表table -->
					<BaseTable
							:data="prdAffirmList"
							:columns="columnsAffirm"
							:tableHeight="tableHt"
							:pagination="false" >
						<el-table-column fixed="right" align="center" label="操作" slot="operationColumn" width="220px">
							<template slot-scope="scope">
								<el-button
										size="mini"
										title="详情"
										v-hasPermi="['metaDataManagement:Customer:customerUpdate']"
										@click.stop="handleDetailed(scope.row)"
								>
						<span style="color: #0b6cd6">
							<i class="iconfont icon-1-07"></i>
							详情
						</span>
								</el-button>

								<el-button
										size="mini"
										title="撤销"
										v-hasPermi="['dryingManagement:storageManagement']"
										@click.stop="handlerCancel(scope.row)"
								>
						<span style="color: #f75e5e">
							<i class="iconfont icon-1-08"></i>
							撤销
						</span>
								</el-button>
							</template>
						</el-table-column>
					</BaseTable>
				</el-tab-pane>
				<el-tab-pane label="堆存费明细" name="second">
					<!-- 主列表table -->
					<BaseTable
							:data="prdAffirmList"
							:columns="columnsAffirmDc"
							:tableHeight="tableHt"
							:pagination="false" >
						<el-table-column fixed="right" align="center" label="操作" slot="operationColumn" width="220px">
							<template slot-scope="scope">
								<el-button
										size="mini"
										title="详情"
										v-hasPermi="['metaDataManagement:Customer:customerUpdate']"
										@click.stop="handleDetailed(scope.row)"
								>
						<span style="color: #0b6cd6">
							<i class="iconfont icon-1-07"></i>
							详情
						</span>
								</el-button>
							</template>
						</el-table-column>
					</BaseTable>
				</el-tab-pane>

			</el-tabs>
		</div>


		<el-drawer title="详情" :visible.sync="isShow" direction="rtl" size="70%">
			<div>
				<el-tabs v-model="activeNameXq" type="card" @tab-click="handleXqClick(activeNameXq)">
					<el-tab-pane label="入库记录" name="first">
						<!-- 主列表table -->
						<BaseTable
								:data="TableDetailedList"
								:columns="columnsTake"
								:tableHeight="tableHeight2"
								:pagination="false" >
						</BaseTable>
					</el-tab-pane>
					<el-tab-pane label="放货记录" name="second">
						<!-- 主列表table -->
						<BaseTable
								:data="TableDetailedList"
								:columns="columnsTake"
								:tableHeight="tableHeight2"
								:pagination="false" >
						</BaseTable>
					</el-tab-pane>
					<el-tab-pane label="货物明细" name="three">
						<!-- 主列表table -->
						<BaseTable
								:data="CargoDetailedList"
								:columns="columnsTakeDetailed"
								:tableHeight="tableHeight2"
								:pagination="false" >
						</BaseTable>
					</el-tab-pane>
				</el-tabs>
			</div>
			<div class="demo-drawer__footer">
				<el-button  size="small" type="primary" @click="isShow = false">确 定</el-button>
			</div>
		</el-drawer>
		<!-- 收货入库 -->
		<el-drawer title="收货入库" :visible.sync="isReceiptShow" direction="rtl" size="80%" :before-close="visibleReceiptChange">
			<el-form :model="receiptFrom" ref="receiptRulesRef" :rules="receiptFromRules" style="padding: 10px 10px" label-position="top">
				<el-row  class="receiptFrom">
					<el-col :span="8">
						<el-form-item label="订单编号：" prop="orderNo" style="display: flex">
							<el-input size="mini" v-model="receiptFrom.orderNo" disabled style="width: 80%"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="车号：" prop="truckNo" style="display: flex">
							<el-input v-model="receiptFrom.truckNo" size="mini" clearable style="width: 80%"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="日期：" prop="workDate" style="display: flex">
							<el-date-picker
								v-model="receiptFrom.workDate"
								type="date"
								style="width: 80%"
								size="mini"
								placeholder="选择日期"
							></el-date-picker>
						</el-form-item>
					</el-col>

				</el-row>

				<el-row  class="receiptFrom">
					<el-col :span="8">
						<el-form-item label="批次：" prop="batch" style="display: flex">
							<el-select v-model="receiptFrom.batch" placeholder="请选择" clearable size="mini" style="width: 80%">
								<el-option
										v-for="(item,index) in batchList"
										:key="index"
										:label="item.label"
										:value="item.value">
								</el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="16">
						<el-form-item label="树种" prop="orderItemId" style="display: flex">
							<el-select v-model="receiptFrom.orderItemId" placeholder="请选择" clearable size="mini" style="width: 80%">
								<el-option
										v-for="(item,index) in orderItemIdList"
										:key="index"
										:label="item.label"
										:value="item.value">
								</el-option>
							</el-select>
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
			<!-- 标题 -->
			<div class="receiptTableTitle">
				<div class="receiptTableTitle-total">
					总包数：{{ Number(packages).toFixed(3) }} 总根数：{{ Number(quantity).toFixed(3) }} 总方数：{{
						Number(volume).toFixed(3)
					}}
				</div>
				<div class="receiptTableTitle-btn">
					<el-button size="mini" type="primary" @click="increaseRow">添 加</el-button>
				</div>
			</div>
			<!-- 表格 -->
			<div class="receiptTable">
				<el-form :model="receiptFrom" ref="receiptRulesRef" style="padding: 10px 10px" label-position="top">
					<el-table
						:data="receiptFrom.receiptTableData"
						border
						@row-click="selectReceiptData"
						style="width: 100%"
						:pagination="false"
						:tableHeight="200"
					>
						<el-table-column label="商品名称">
							<template slot-scope="scope">
								<el-form-item label="" :rules="[{ required: true, message: '商品名称不能为空' }]" :prop="'receiptTableData.' + scope.$index + '.productName'">
									<el-input
										size="mini"
										v-model="scope.row.productName"
										style="width: 100%"
										placeholder="商品名称"
										clearable
									/>
								</el-form-item>
							</template>
						</el-table-column>
						<el-table-column label="包号">
							<template slot-scope="scope">
								<el-form-item label="" :rules="[{ required: true, message: '包号不能为空' }]" :prop="'receiptTableData.' + scope.$index + '.packageNo'">
									<el-input
										size="mini"
										v-model="scope.row.packageNo"
										style="width: 100%"
										@change="computeInfo"
										placeholder="包号"
										clearable
									/>
								</el-form-item>
							</template>
						</el-table-column>
						<el-table-column label="根数">
							<template slot-scope="scope">
								<el-form-item label="" :rules="[{ required: true, message: '根数不能为空' }]" :prop="'receiptTableData.' + scope.$index + '.quantity'">
									<el-input
										size="mini"
										v-model="scope.row.quantity"
										style="width: 100%"
										@change="computeInfo"
										placeholder="根数"
										clearable
									/>
								</el-form-item>
							</template>
						</el-table-column>
						<el-table-column label="方量">
							<template slot-scope="scope">
								<el-form-item label="" :rules="[{ required: true, message: '方量不能为空' }]" :prop="'receiptTableData.' + scope.$index + '.volume'">
									<el-input
										v-model="scope.row.volume"
										style="width: 100%"
										size="mini"
										placeholder="方数"
										@change="computeInfo"
										clearable
									/>
								</el-form-item>
							</template>
						</el-table-column>
						<el-table-column label="操作">
							<template slot-scope="scope">
								<el-button size="mini" style="color: #fff !important" type="primary" @click="handleDelete(scope.$index, receiptFrom.receiptTableData)">
									删 除
								</el-button>
								<el-button size="mini" style="color: #fff !important" type="primary" @click="handleDuplicate(scope.row)">
									复 制
								</el-button>
							</template>
						</el-table-column>
					</el-table>
				</el-form>
			</div>
			<!-- 保存 -->
			<div class="demo-drawer__footer">
				<el-button size="mini" type="primary" @click="addReceiptUpdate()">保 存</el-button>
			</div>
		</el-drawer>
		<!-- 入窑管理 -->
		<div class="otherClass">
			<el-drawer title="入窑管理" :visible.sync="showType" size="80%" :before-close="visibleChange">
				<div class="kilnEntry">
					<div class="kilnEntryRow">
						<el-form
							:model="kilnEntryFrom"
							ref="basisRulesRef"
							style="padding: 10px 10px"
							label-position="top"
							label-width="auto"
						>
							<el-row  >
								<el-col :span="4">
									<el-form-item label="订单编号：" style="display: flex">
										<el-input size="mini" v-model="kilnEntryFrom.orderNo" clearable></el-input>
									</el-form-item>
								</el-col>

								<el-col :span="14">
									<div style="margin-top: 6px">
										<el-button size="mini" type="primary" @click="batchKilnChange" :disabled="batchKilnDisable">
											批量入窑
										</el-button>
										<el-button size="mini" type="primary" @click="entryKilnChange" :disabled="entryKilnDisable">
											入窑
										</el-button>
									</div>
								</el-col>
							</el-row>
						</el-form>
					</div>
					<div class="kilEntryTableBox">
						<div class="kilEntryTitle">
							<div class="kilEntryTitle-total">
								<i class="el-icon-info" style="color: #078fea"></i>
								总根数：{{ Number(kilnEntryFrom.quantity).toFixed(3) }} 总方量：{{
									Number(kilnEntryFrom.volume).toFixed(3)
								}}
							</div>
						</div>
						<div class="kilEntryTable">
							<baseTablecheck
								:data="kilEntryTableData"
								:tableHT="300"
								:tableHeight="300"
								:columns="kilEntryColumns"
								:pagination="false"
								@checkId="handleSelectionChange"
								ref="kilEntryChange"
							></baseTablecheck>
						</div>
					</div>
				</div>
				<!-- <div class="demo-drawer__footer">
					<el-button size="small" type="primary" @click="()">保 存</el-button>
				</div> -->
			</el-drawer>
			<!-- 批量入窑 -->
			<el-dialog title="批量入窑" :visible.sync="batchPlacingShowType" width="70%" :before-close="batchPlacingClose">
				<div class="placingBox">
					<el-form
						:model="batchEntryPlacingFrom"
						ref="batchPlacingRulesRef"
						:rules="batchEntryPlacingRules"
						style="padding: 10px 10px"
						label-position="top"
					>
						<el-row :gutter="24">
							<el-col :span="8">
								<el-form-item label="总根数：" class="batchEntryPlacingFrom" style="display: flex">
									<el-input size="mini" :disabled="true" v-model="batchEntryPlacingFrom.quantity" clearable></el-input>
								</el-form-item>
							</el-col>
							<el-col :span="8">
								<el-form-item label="总包数：" class="batchEntryPlacingFrom" style="display: flex">
									<el-input size="mini" :disabled="true" v-model="batchEntryPlacingFrom.packages" clearable></el-input>
								</el-form-item>
							</el-col>
							<el-col :span="8">
								<el-form-item label="总方量：" class="batchEntryPlacingFrom" style="display: flex">
									<el-input size="mini" :disabled="true" v-model="batchEntryPlacingFrom.volume" clearable></el-input>
								</el-form-item>
							</el-col>
						</el-row>
						<el-row :gutter="24">
							<el-col :span="8">
								<el-form-item label="入窑日期：" class="batchEntryPlacingFrom" style="display: flex" prop="workDate">
									<el-date-picker
										v-model="batchEntryPlacingFrom.workDate"
										type="date"
										size="mini"
										placeholder="选择日期"
										style="width: 85%"
									></el-date-picker>
								</el-form-item>
							</el-col>
							<el-col :span="8">
								<el-form-item label="是否码板：" class="batchEntryPlacingFrom" style="display: flex" prop="isWet">
									<el-radio-group v-model="batchEntryPlacingFrom.isWet" style="width: 100%">
										<el-radio value="Y" label="Y">是</el-radio>
										<el-radio value="N" label="N">否</el-radio>
									</el-radio-group>
								</el-form-item>
							</el-col>
						</el-row>
						<el-row :gutter="24">
							<el-col :span="8">
								<el-form-item label="窑号：" class="batchEntryPlacingFrom" style="display: flex" prop="kilnCode">
									<el-select
										v-model="batchEntryPlacingFrom.kilnCode"
										style="width: 100%"
										placeholder="请选择窑号"
										size="mini"
										ref="seletPort"
									>
										<el-option
											v-for="item in entryPlacingList"
											:key="item.dictValue"
											:label="item.dictLabel"
											:value="item.dictValue"
										></el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="8">
								<el-form-item label="入窑编号：" class="batchEntryPlacingFrom" style="display: flex" prop="enterKilnNo">
									<el-input size="mini" v-model="batchEntryPlacingFrom.enterKilnNo" clearable></el-input>
								</el-form-item>
							</el-col>
						</el-row>
					</el-form>
				</div>
				<div slot="footer" class="dialog-footer">
					<el-button type="primary" size="mini" @click="storeInKilnEvent('kilnEntryBatch')">提 交</el-button>
				</div>
			</el-dialog>
			<!-- 入窑 -->
			<el-dialog title="入窑" :visible.sync="entryPlacingShowType" width="70%" :before-close="entryPlacingClose">
				<div class="placingBox">
					<el-form
						:model="entryPlacingFrom"
						ref="entryPlacingRulesRef"
						:rules="entryPlacingRules"
						style="padding: 10px 10px"
						label-position="top"
					>
						<el-row :gutter="24">
							<el-col :span="8">
								<el-form-item label="入窑日期：" prop="workDate" class="entryPlacingFrom" style="display: flex">
									<el-date-picker
										v-model="entryPlacingFrom.workDate"
										type="date"
										size="mini"
										style="width: 85%"
										placeholder="选择日期"
									></el-date-picker>
								</el-form-item>
							</el-col>
							<el-col :span="8">
								<el-form-item label="是否码板：" prop="isWet" class="entryPlacingFrom" style="display: flex">
									<el-radio-group v-model="entryPlacingFrom.isWet" style="width: 100%">
										<el-radio value="Y" label="Y">是</el-radio>
										<el-radio value="N" label="N">否</el-radio>
									</el-radio-group>
								</el-form-item>
							</el-col>
							<el-col :span="8">
								<el-form-item label="车号：" prop="truckNo" class="entryPlacingFrom" style="display: flex">
									<el-input disabled v-model="entryPlacingFrom.truckNo" size="mini" clearable></el-input>
								</el-form-item>
							</el-col>
						</el-row>
						<el-row :gutter="24">
							<el-col :span="8">
								<el-form-item label="窑号：" class="entryPlacingFrom" prop="kilnCode" style="display: flex">
									<el-select v-model="entryPlacingFrom.kilnCode" style="width: 100%" placeholder="请选择窑号" size="mini">
										<el-option
											v-for="item in entryPlacingList"
											:key="item.dictValue"
											:label="item.dictLabel"
											:value="item.dictValue"
										></el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="8">
								<el-form-item label="入窑编号：" class="entryPlacingFrom" prop="enterKilnNo" style="display: flex">
									<el-input size="mini" v-model="entryPlacingFrom.enterKilnNo" clearable></el-input>
								</el-form-item>
							</el-col>
							<el-col :span="8"></el-col>
						</el-row>
					</el-form>
				</div>
				<div class="entryPlacingTable">
					<el-form :model="entryPlacingFrom" ref="storageFeeRef" style="padding: 10px 10px" label-position="top">
						<el-table
							:data="entryPlacingFrom.entryPlacingTable"
							border
							style="width: 100%"
							:pagination="false"
							:tableHeight="200"
							@selection-change="handleKilnEntryChange"
							ref="kilnEntryOneRef"
						>
							<el-table-column type="selection" width="55"></el-table-column>
							<el-table-column label="商品名称">
								<template slot-scope="scope">
									<el-form-item label="" :prop="'entryPlacingTable.' + scope.$index + '.productName'">
										<el-input
											disabled
											size="mini"
											v-model="scope.row.productName"
											style="width: 100%"
											placeholder="商品名称"
											clearable
										/>
									</el-form-item>
								</template>
							</el-table-column>
							<el-table-column label="包号">
								<template slot-scope="scope">
									<el-form-item label="" :prop="'entryPlacingTable.' + scope.$index + '.packageNo'">
										<el-input
											disabled
											size="mini"
											v-model="scope.row.packageNo"
											style="width: 100%"
											placeholder="包号"
											clearable
										/>
									</el-form-item>
								</template>
							</el-table-column>
							<el-table-column label="根数">
								<template slot-scope="scope">
									<el-form-item label="" :prop="'entryPlacingTable.' + scope.$index + '.quantity'">
										<el-input
											size="mini"
											disabled
											v-model="scope.row.quantity"
											style="width: 100%"
											placeholder="根数"
											clearable
										/>
									</el-form-item>
								</template>
							</el-table-column>
							<el-table-column label="方量">
								<template slot-scope="scope">
									<el-form-item label="" :prop="'entryPlacingTable.' + scope.$index + '.volume'">
										<el-input disabled size="mini" v-model="scope.row.volume" style="width: 100%" placeholder="方量" clearable />
									</el-form-item>
								</template>
							</el-table-column>
						</el-table>
					</el-form>
				</div>
				<div slot="footer" class="dialog-footer">
					<el-button type="primary" size="mini" @click="storeInKilnEvent('kilnEntryOne')">提 交</el-button>
				</div>
			</el-dialog>
		</div>
		<!-- 出窑管理 -->
		<div class="kilnDischargeBox">
			<el-drawer title="出窑管理" :visible.sync="iskilnDischargeShow" direction="rtl" size="80%" :before-close="visibleDischarge">
				<div class="kilnDischargeRow">
					<el-form :model="kilnDischargeFrom" ref="kilnDischargeRulesRef" style="padding: 10px 10px" label-position="top">
						<el-row :gutter="24" style="display: flex">
							<el-col :span="5">
								<el-form-item label="订单编号：" class="kilnDischarge">
									<el-input size="mini" v-model="kilnDischargeFrom.orderNo" clearable></el-input>
								</el-form-item>
							</el-col>
							<el-col :span="5">
								<el-form-item label="入窑编号：" class="kilnDischarge">
									<el-input size="mini" v-model="kilnDischargeFrom.enterKilnNo" clearable></el-input>
								</el-form-item>
							</el-col>

							<el-col :span="10" style="padding: 6px">
								<el-button size="mini" type="primary" @click="queryKilnChange">查询</el-button>
								<el-button size="mini" type="primary" @click="kilnDischargeHandle('0')">出窑</el-button>
								<el-button size="mini" type="primary" @click="kilnDischargeHandle('1')">转窑</el-button>
							</el-col>
						</el-row>
					</el-form>
				</div>
				<div class="kilnDischargeTableBox">
					<div class="kilnDischargeTitle">
						<div class="kilnDischargeTitle-total">
							<i class="el-icon-info" style="color: #078fea"></i>
							总根数：{{ Number(kilnDischargeFrom.quantity).toFixed(3) }} 总方量：{{
								Number(kilnDischargeFrom.volume).toFixed(3)
							}}
						</div>
					</div>
					<div class="kilnDischargeTab">
						<baseTablecheck
							:data="kilnDischargeTableData"
							:tableHT="300"
							:tableHeight="300"
							:columns="kilnDischargeColumns"
							:pagination="false"
							@checkId="handleKilnDisChange"
							ref="kilnDischargeTable"
						></baseTablecheck>
					</div>
				</div>
			</el-drawer>
			<!-- 出窑弹窗 -->
			<el-dialog
				:title="kilnStatus === '0' ? '出窑' : '转窑'"
				:visible.sync="kilnDischargeVisible"
				width="25%"
				:before-close="kilnDischargeColse"
			>
				<el-form :model="kilnDischargeDialogFrom" ref="kilnDischargeRef" :rules="kilnDischargeRules" label-width="100px">
					<el-form-item label="出窑日期：" v-if="kilnStatus === '0'" prop="exitKilnDate">
						<el-date-picker
							v-model="kilnDischargeDialogFrom.exitKilnDate"
							type="date"
							size="mini"
							placeholder="选择日期"
							style="width: 100%"
						></el-date-picker>
					</el-form-item>

					<el-form-item label="是否抽条：" v-if="kilnStatus === '0'" prop="isDry">
						<el-radio-group v-model="kilnDischargeDialogFrom.isDry" style="width: 100%">
							<el-radio value="Y" label="Y">是</el-radio>
							<el-radio value="N" label="N">否</el-radio>
						</el-radio-group>
					</el-form-item>
					<el-form-item label="是否分选：" v-if="kilnStatus === '0'" prop="isSort">
						<el-radio-group v-model="kilnDischargeDialogFrom.isSort" style="width: 100%">
							<el-radio value="Y" label="Y">是</el-radio>
							<el-radio value="N" label="N">否</el-radio>
						</el-radio-group>
					</el-form-item>
					<el-form-item label="转窑日期：" v-if="kilnStatus === '1'" prop="turnKilnDate">
						<el-date-picker
							v-model="kilnDischargeDialogFrom.turnKilnDate"
							type="date"
							size="mini"
							placeholder="选择日期"
							style="width: 100%"
						></el-date-picker>
					</el-form-item>
					<el-form-item label="转入窑号：" v-if="kilnStatus === '1'" prop="turnKilnCode">
						<el-select v-model="kilnDischargeDialogFrom.turnKilnCode" style="width: 100%" placeholder="请选择窑号" size="mini">
							<el-option
								v-for="item in entryPlacingList"
								:key="item.dictValue"
								:label="item.dictLabel"
								:value="item.dictValue"
							></el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="入窑编号：" v-if="kilnStatus === '1'" prop="turnKilnNo">
						<el-input size="mini" v-model="kilnDischargeDialogFrom.turnKilnNo" clearable style="width: 100%"></el-input>
					</el-form-item>
				</el-form>
				<div slot="footer" class="dialog-footer">
					<el-button size="mini" @click="kilnDischargeVisible = false">取 消</el-button>
					<!-- 出窑确定 -->
					<el-button size="mini" type="primary" v-if="kilnStatus === '0'" @click="kilnRotaryHandle('0')">确 定</el-button>
					<!-- 转窑确定 -->
					<el-button size="mini" type="primary" v-if="kilnStatus === '1'" @click="kilnRotaryHandle('1')">确 定</el-button>
				</div>
			</el-dialog>
		</div>
		<!-- 放货管理 -->
		<div class="releaseDown">
			<el-drawer title="放货管理" :visible.sync="isReleaseDownShow" direction="rtl" size="80%" :before-close="visibleReleaseDown">
				<div class="releaseDownRow">
					<el-form :model="releaseDownFrom" ref="kilnDischargeRulesRef" style="padding: 10px 10px" label-position="top">
						<el-row :gutter="24" style="display: flex">
							<el-col :span="5">
								<el-form-item label="订单编号：" class="kilnDischarge" style="display: flex">
									<el-input size="mini" v-model="releaseDownFrom.orderNo" clearable></el-input>
								</el-form-item>
							</el-col>
							<el-col :span="4">
								<el-form-item label="是否放货：" class="kilnDischarge" style="display: flex">
									<el-select
										v-model="releaseDownFrom.status"
										style="width: 100%"
										placeholder="请选择是否放货"
										size="mini"
										ref="seletPort"
									>
										<el-option
											v-for="item in releaseDownList"
											:key="item.dictValue"
											:label="item.dictLabel"
											:value="item.dictValue"
										></el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="10" style="padding: 6px">
								<el-button size="mini" type="primary" @click="queryReleaseDown">查询</el-button>
								<el-button size="mini" :disabled="releaseDownFrom.status == '4'" type="primary" @click="deliveryHandle">
									放货
								</el-button>
							</el-col>
						</el-row>
					</el-form>
				</div>
				<div >
					<baseTablecheck
						:data="releaseDownTableData"
						:tableHT="tableHeight2"
						:tableHeight="tableHeight2"
						:columns="releaseDownColumns"
						:pagination="false"
						@checkId="handleReleaseDown"
						ref="releaseDownTable"
					></baseTablecheck>
				</div>
			</el-drawer>
			<el-dialog title="放货" :visible.sync="dialogReleaseDown" width="20%" :before-close="releaseDownClose">
				<el-form :model="releaseDownDialogFrom" ref="releaseDownDialogRef" :rules="releaseDownDialogRules" label-width="100px">
					<!-- <el-form-item label="出窑日期：">
						<el-date-picker
							v-model="releaseDownDialogFrom.exitKilnDate"
							type="date"
							size="mini"
							placeholder="选择日期"
							style="width: 100%"
							 clearable
						></el-date-picker>
					</el-form-item> -->
					<el-form-item label="放货日期：" prop="releaseDate">
						<el-date-picker
							v-model="releaseDownDialogFrom.releaseDate"
							type="date"
							size="mini"
							placeholder="选择日期"
							style="width: 100%"
							clearable
						></el-date-picker>
					</el-form-item>
					<!-- <el-form-item label="堆存天数:">
						<el-input size="mini" v-model="releaseDownDialogFrom.day" autocomplete="off" style="width: 100%"  clearable></el-input>
					</el-form-item> -->
					<el-form-item label="车号：" prop="truckNo">
						<el-input
							size="mini"
							v-model="releaseDownDialogFrom.truckNo"
							autocomplete="off"
							style="width: 100%"
							clearable
						></el-input>
					</el-form-item>
				</el-form>
				<div slot="footer" class="dialog-footer">
					<el-button size="mini" @click="dialogReleaseDown = false">取 消</el-button>
					<el-button size="mini" type="primary" @click="releaseDownDetermine">确 定</el-button>
				</div>
			</el-dialog>
		</div>
		<!--入库单-->
		<el-drawer title="入库单" :visible.sync="isShowConfirmed" direction="rtl" size="70%">
				<div style="margin: 20px">
					<el-row :gutter="20">
						<el-col :span="8">
							<div style="margin-bottom: 10px">
								订单编号:
							</div>
							<el-input v-model="selectInfoCon.orderNo" disabled size="small"></el-input>
						</el-col>
						<el-col :span="8">
							<div style="margin-bottom: 10px">
								客户名称:
							</div>
							<el-input v-model="selectInfoCon.customerName" disabled size="small"></el-input>
						</el-col>
						<el-col :span="8">
							<div style="margin-bottom: 10px">
								树种:
							</div>
							<el-input v-model="selectInfoCon.treeSpeciesName" disabled size="small"></el-input>
						</el-col>
					</el-row>
				</div>

			<div style="margin: 20px">
				<el-row :gutter="20">
					<el-col :span="8">
						<div style="margin-bottom: 10px">
							方量:
						</div>
						<el-input v-model="selectInfoCon.quantity" disabled size="small"></el-input>
					</el-col>
					<el-col :span="16">
						<div style="margin-bottom: 10px">
							备注:
						</div>
						<el-input v-model="remark"  size="small"></el-input>
					</el-col>
				</el-row>
			</div>

				<div class="titleclass2">
					<span style="margin-left: 18px">入库记录</span>
					<div></div>

				</div>
				<el-row>
					<el-table
							:data="confirmedList"
							stripe
							ref="multipleTable"
							@selection-change="confirmedSelectionChange"
							style="width: 100%">
						<el-table-column
								type="selection"
								width="55">
						</el-table-column>
						<el-table-column
								prop="truckNo"
								label="车号"
								>
						</el-table-column>
						<el-table-column
								prop="createTime"
								label="入库日期"
						>
						</el-table-column>
						<el-table-column
								prop="batch"
								label="批次"
						>
						</el-table-column>
						<el-table-column
								prop="quantity"
								label="件数"
						>
						</el-table-column>
						<el-table-column
								prop="packages"
								label="包数"
						>
						</el-table-column>
						<el-table-column
								prop="volume"
								label="方数"
						>
						</el-table-column>

					</el-table>
<!--					<baseTablecheck-->
<!--							ref="oddJobApply"-->
<!--							:data="confirmedList"-->
<!--							:columns="columnsConfirmed"-->
<!--							:tableHT="tableHeight"-->
<!--							:pagination="false"-->
<!--							@checkId="confirmedSelectionChange"></baseTablecheck>-->

				</el-row>

			<div class="demo-drawer__footer">
				<el-button v-if="isAudit != '1'" size="small" type="primary" @click="submitconfirmed()">确 认</el-button>
			</div>
		</el-drawer>

		<!--确认单详情-->
		<el-drawer title="详情" :visible.sync="isShowDetailed" direction="rtl" size="70%">
			<div>
				<BaseTable
						:data="handleDetailedList"
						:columns="columnsTakeDetailed"
						:tableHeight="tableHeight2"
						:pagination="false" >
				</BaseTable>
			</div>
			<div class="demo-drawer__footer">
				<el-button  size="small" type="primary" @click="isShowDetailed = false">确 定</el-button>
			</div>
		</el-drawer>
	</div>
</template>
<script>
import BaseTable from "@/components/BaseTable"
import publicapi from "@/api/public/index"
import api from "@/api/Business/dryingOrder/index"
import dryingApi from "@/api/Product/dryingManagement/index"
import baseTablecheck from "@/components/BaseTable/baseTablecheck" //表格组件
import store from '@/store/index.js' // 引入store
export default {
	components: { BaseTable, baseTablecheck },
	data() {
		return {
			menuArr: [],
			// 搜索表单
			searchForm: {
				orderNo: "",
				treeSpeciesCode: "",
				customerId: "",
			},
			isShowConfirmed:false,
			isShowDetailed:false,
			cusList: [], // 客户list
			cargoList: [], // 货名list
			loading: false,
			tableData: [],
			columnsAffirmDetailed : [
				{
					prop: "orderNo",
					label: "订单编号",
				},
				{
					prop: "truckNo",
					label: "车牌号",
				},
				// {
				// 	prop: "batch",
				// 	label: "批次",
				// },
				{
					prop: "quantity",
					label: "件数",
				},
				{
					prop: "packages",
					label: "包数",
				},
				{
					prop: "volume",
					label: "方数",
				},
			],
			columnsAffirm : [
				{
					prop: "volume",
					label: "方数",
				},

				{
					prop: "createName",
					label: "确认人",
				},
				{
					prop: "createTime",
					label: "确认时间",
				},
				{
					prop: "remark",
					label: "备注",
				},

				{
					prop: "status",
					label: "状态",
					render(h, params) {
						if (params.row.status == "1") {
							return h("el-tag", {
								props: {
									size: "mini",
								},
								domProps: {
									innerHTML: "未结算",
								},
							})
						} else if (params.row.status == "2") {
							return h("el-tag", {
								props: {
									size: "mini",
									type: "warning",
								},
								domProps: {
									innerHTML: "已结算",
								},
							})
						}
					},
				},
			],
			columnsAffirmDc : [
				// {
				// 	prop: 'truckNo',
				// 	label: '车号',
				// },
				{
					prop: "volume",
					label: "方数",
				},

				{
					prop: "createName",
					label: "确认人",
				},
				{
					prop: "createTime",
					label: "确认时间",
				},
				{
					prop: "remark",
					label: "备注",
				},

				{
					prop: "status",
					label: "状态",
					render(h, params) {
						if (params.row.status == "1") {
							return h("el-tag", {
								props: {
									size: "mini",
								},
								domProps: {
									innerHTML: "未结算",
								},
							})
						} else if (params.row.status == "2") {
							return h("el-tag", {
								props: {
									size: "mini",
									type: "warning",
								},
								domProps: {
									innerHTML: "已结算",
								},
							})
						}
					},
				},
			],
			columns: [
				{
					prop: "orderNo",
					label: "订单编号",
				},
				{
					prop: "customerName",
					label: "客户名称",
					isShort: true,
				},
				{
					prop: "contacts",
					label: "联系人",
				},
				{
					prop: "contactNumber",
					label: "联系电话",
				},
				{
					prop: "treeSpeciesName",
					label: "树种",
				},
				{
					prop: "quantity",
					label: "计划件数",
				},
				{
					prop: "packages",
					label: "计划包数",
				},
				{
					prop: "volume",
					label: "计划方数",
				},
				{
					prop: "status",
					label: "状态",
					render(h, params) {
						if (params.row.status == "1") {
							return h("el-tag", {
								props: {
									size: "mini",
								},
								domProps: {
									innerHTML: "未审核",
								},
							})
						} else if (params.row.status == "2") {
							return h("el-tag", {
								props: {
									size: "mini",
									type: "warning",
								},
								domProps: {
									innerHTML: "已下单",
								},
							})
						} else if (params.row.status == "3") {
							return h("el-tag", {
								props: {
									size: "mini",
									type: "danger",
								},
								domProps: {
									innerHTML: "作业中",
								},
							})
						} else if (params.row.status == "4") {
							return h("el-tag", {
								props: {
									size: "mini",
									type: "success",
								},
								domProps: {
									innerHTML: "已结算",
								},
							})
						}
					},
				},
			],
			tableHeight: 200,
			tableHt: window.innerHeight - 450,
			tableHeight2: window.innerHeight - 100,
			// 页码
			queryall: {
				totalNum: 0,
				startpage: 1,
				pagesize: 15,
			},
			isShow: false,
			form: {
				companyId: "",
				companyName: "",
				customerCode: "",
				customerName: "",
				orderNo: "",
				contacts: "",
				remark: "",
				contactNumber: "",
				cargoInfoList: [],
			},
			companyList: [], // 公司
			selectInfo: null, // 主列表行数据
			selectInfoCon:{
				orderNo:'',
				cargoName:'',
				treeSpeciesName:'',
				quantity:''
			},
			remark:'',
			activeName:'first',
			activeNameXq:'first',
			settlementType:1,
			bussinessType:1,
			labourDemandList: [], // 劳务需求
			checkedDemand: [], // 选中的劳务需求
			isAudit: "", // 是否审核
			isReceiptShow: false,
			// 收货入库列表数据
			receiptFrom: {
				orderNo: "", //订单编号
				batch: "", //批次
				truckNo: "", //车号
				workDate: "", //作业日期
				orderItemId:"", //订单子表ID
				// 收货入库列表数据
				receiptTableData: [],
			},
			receiptFromRules: {
				orderNo: [{ required: true, message: "订单编号不能为空", trigger: "blur" }], //订单编号
				// batch: [{ required: true, message: "批次不能为空", trigger: "blur" }], //批次
				orderItemId: [{ required: true, message: "树种不能为空", trigger: "blur" }], //批次
				truckNo: [{ required: true, message: "车号不能为空", trigger: "change" }], //车号
				workDate: [{ required: true, message: "日期不能为空", trigger: "blur" }], //作业日期
			},
			quantity: "0", //总件数，数据条数加起来
			packages: "0", //总包数，加起来
			volume: "0", //方数，加起来
			columnsConfirmed: [
				{
					prop: 'truckNo',
					label: '车号',
				},
				{
					prop: 'createTime',
					label: '入库日期'
				},
				{
					prop: 'batch',
					label: '批次',
				},
				{
					prop: 'quantity',
					label: '件数',
				},
				{
					prop: 'packages',
					label: '包数',
				},
				{
					prop: 'volume',
					label: '方数',
				},
			],
			columnsTake: [
				{
					prop: 'orderNo',
					label: '订单编号'
				},
				{
					prop: 'truckNo',
					label: '车号',
				},
				{
					prop: 'workDate',
					label: '日期',
				},

				// {
				// 	prop: 'batch',
				// 	label: '批次',
				// },
				{
					prop: 'quantity',
					label: '件数',
				},
				{
					prop: 'packages',
					label: '包数',
				},
				{
					prop: 'volume',
					label: '方数',
				},
			],
			columnsTakeDetailed: [
				{
					prop: 'productName',
					label: '品名'
				},
				{
					prop: 'packageNo',
					label: '包号',
				},
				{
					prop: 'quantity',
					label: '件数',
				},

				{
					prop: 'volume',
					label: '方数',
				},

				{
					prop: 'enterKilnDate',
					label: '入窑日期',
				},
				{
					prop: 'enterKilnNo',
					label: '入窑编号',
				},
				{
					prop: 'kilnName',
					label: '窑号',
				},
				{
					prop: 'exitKilnDate',
					label: '出窑日期',
				},
				{
					prop: 'releaseDate',
					label: '放货日期',
				},

			],
			// 入窑from
			entryPlacingFrom: {
				workDate: "", //入窑日期
				isWet: "Y", //isWet
				kilnCode: "", //窑代码
				kilnName: "", //窑号
				enterKilnNo: "", // 入窑编号
				truckNo: "", //车号
				// 入窑table
				entryPlacingTable: [],
			},
			// 入窑显示
			entryPlacingShowType: false,
			// 批量入窑
			batchEntryPlacingFrom: {
				quantity: "", //总根数
				packages: "", //总包数
				volume: "", //总方量
				workDate: "", //入窑日期
				isWet: "Y", //是否码板
				kilnCode: "", //窑号
				enterKilnNo: "", // 入窑编号
			},
			// 窑号
			entryPlacingList: [],
			// 批量入窑显示
			batchPlacingShowType: false,
			// 入窑管理
			kilnEntryFrom: {
				orderId: "",
				// 总根数
				quantity: "",
				// 总方量
				volume: "",
			},
			// 表格数据
			kilEntryTableData: [],
			// 入窑管理表格列
			kilEntryColumns: [
				{
					label: "车号",
					prop: "truckNo",
				},
				{
					label: "入库日期",
					prop: "workDate",
				},
				{
					label: "批次",
					prop: "batch",
				},
				{
					label: "根数",
					prop: "quantity",
				},
				{
					label: "方量",
					prop: "volume",
				},
			],
			// 入窑校验
			entryPlacingRules: {
				workDate: [{ required: true, message: "请选择入窑日期", trigger: "blur" }],
				isWet: [{ required: true, message: "请选择是否码板", trigger: "change" }],
				kilnCode: [{ required: true, message: "请选择窑号", trigger: "change" }],
				enterKilnNo: [{ required: true, message: "请输入入窑编号", trigger: "blur" }],
			},
			// 批量入窑校验
			batchEntryPlacingRules: {
				workDate: [{ required: true, message: "请选择入窑日期", trigger: "blur" }],
				isWet: [{ required: true, message: "请选择是否码板", trigger: "change" }],
				kilnCode: [{ required: true, message: "请选择窑号", trigger: "change" }],
				enterKilnNo: [{ required: true, message: "请输入入窑编号", trigger: "blur" }],
			},
			showType: false,
			loading: false,
			// 单入窑
			entryKilnDisable: false,
			// 批量入窑
			batchKilnDisable: false,
			// 入窑选中数据
			selectChangeRow: null,
			// 单个入窑表格选中数据
			selectKilnEntryList: [],
			submitconfirmedList:[],
			// 出窑管理
			iskilnDischargeShow: false,
			// 出窑查询条件
			kilnDischargeFrom: {
				orderNo: "", //订单号
				enterKilnNo: "", //入窑编号
				quantity: "", //总根数
				volume: "", //总方量
			},
			kilnDischargeTableData: [], //出窑表格
			kilnDischargeColumns: [
				{
					label: "订单号",
					prop: "orderNo",
				},
				{
					label: "窑号",
					prop: "kilnName",
				},
				{
					label: "入窑编号",
					prop: "enterKilnNo",
				},
				{
					label: "入窑日期",
					prop: "enterKilnDate",
				},
				{
					label: "包号",
					prop: "packageNo",
				},
				{
					label: "根数",
					prop: "quantity",
				},
				{
					label: "方量",
					prop: "volume",
				},
			], //出窑表格列
			// 出窑选中列
			kilnDischargeSelectList: null,
			// 出窑小弹窗
			kilnDischargeVisible: false,
			kilnDischargeDialogFrom: {
				exitKilnDate: "", //出窑日期
				isDry: "Y", //是否抽条,Y是N否
				isSort: "N", //是否分选,Y是N否
				enterKilnNo: "", //入窑编号
				turnKilnNo: "", //转窑编号
				turnKilnDate: "", //转窑日期
				kilnCode: "", //窑代码（字典）
				kilnName: "", //窑号（字典）
				turnKilnCode: "", //转窑代码（字典）
				turnKilnName: "", //转窑号（字典）
			},
			kilnDischargeRules: {
				exitKilnDate: [{ required: true, message: "请选择出窑日期", trigger: "blur" }],
				isDry: [{ required: true, message: "请选择是否抽条", trigger: "change" }],
				isSort: [{ required: true, message: "请选择分选", trigger: "change" }],
				turnKilnDate: [{ required: true, message: "请选择转窑日期", trigger: "blur" }],
				turnKilnCode: [{ required: true, message: "请选择转入窑号", trigger: "blur" }],
				turnKilnNo: [{ required: true, message: "请选择入窑编号", trigger: "blur" }],
			},
			// 出窑 转窑判断
			kilnStatus: null,
			// 收货管理显示
			isReleaseDownShow: false,
			// 放货管理
			releaseDownFrom: {
				orderNo: "",
				status: "3",
			},
			releaseDownTableData: [],
			releaseDownColumns: [
				{
					label: "订单号",
					prop: "orderNo",
				},
				{
					label: "品名",
					prop: "productName",
				},
				{
					label: "包名",
					prop: "packageNo",
				},
				{
					label: "出窑日期",
					prop: "exitKilnDate",
				},
				// {
				// 	label: "放货日期",
				// 	prop: "releaseDate",
				// },
				{
					label: "堆存天数",
					prop: "days",
				},
				{
					label: "批次",
					prop: "batch",
				},
				{
					label: "根数",
					prop: "quantity",
				},
				{
					label: "方量",
					prop: "volume",
				},
			],
			batchList:[],
			orderItemIdList:[],
			releaseDownSelectList: null,
			// 放货表单数据
			releaseDownDialogFrom: {
				releaseDate: "",
				truckNo: "",
			},
			zid:'',
			confirmedList:[],
			prdAffirmList:[],
			TableDetailedList:[],
			CargoDetailedList:[],
			handleDetailedList:[],
			// 放货按钮弹窗
			dialogReleaseDown: false,
			// 放货弹窗校验
			releaseDownDialogRules: {
				releaseDate: [{ required: true, message: "请选择放货日期", trigger: "change" }],
				truckNo: [{ required: true, message: "请选择车号", trigger: "blur" }],
			},
			// 是否放货
			releaseDownList: [
				{
					dictLabel: "是",
					dictValue: "4",
				},
				{
					dictLabel: "否",
					dictValue: "3",
				},
			],
		}
	},
	created() {
		this.getCustomer()
		this.getListTreeType()
		this.getCompanyList()
		this.getDictData()
	},
	methods: {
		handleClick (val) {
			if (val == 'first') {
				this.settlementType = 1
				this.getPrdAffirm()
			} else if (val == 'second') {
				this.settlementType = 2
				this.getPrdAffirm()
			}
		},
		handleXqClick (val) {
			if (val == 'first') {
				this.bussinessType = 1
				this.getTableDetailed()
			} else if (val == 'second') {
				this.bussinessType = 2
				this.getTableDetailed()
			}else{
				this.getCargoDetailed()
			}
		},

		/**
		 * 查询入库/放货记录
		 * @returns {Promise<ElMessageComponent>}
		 */
		async getTableDetailed(){
			await this.$http
					.get(`/${this.$ServiceName}/api/external/dryingOperation/getTableDetailed?orderId=${this.zid}&bussinessType=${this.bussinessType}`)
					.then(res => {
						this.TableDetailedList = res.data.data
					})
					.catch(error => {
					})
		},

		/**
		 * 查询货物明细
		 * @returns {Promise<ElMessageComponent>}
		 */
		async getCargoDetailed(){
			await this.$http
					.get(`/${this.$ServiceName}/api/external/dryingOperation/getCargoDetailed?orderId=${this.zid}`)
					.then(res => {
						this.CargoDetailedList = res.data.data
					})
					.catch(error => {
					})
		},

		/**
		 * 查询烘干确认数据
		 * @returns {Promise<ElMessageComponent>}
		 */
		async getPrdAffirm() {
			await this.$http
				.get(`/${this.$ServiceName}/api/external/dryingOperation/getPrdAffirm?orderId=${this.selectInfo.id}&settlementType=${this.settlementType}`)
				.then(res => {
					this.prdAffirmList = res.data.data

				})
				.catch(error => {
				})
		},

		/**
		 * 根据烘干订单查询入库单确认数据
		 * @returns {Promise<ElMessageComponent>}
		 */
		async showConfirmed() {
			if (this.selectInfo == null) {
				return this.$message.info("请先选择一条数据")
			}
			if(this.selectInfo.status ==1){
				return this.$message.error("该数据未审核！！")
			}
			await this.$http
					.get(`/${this.$ServiceName}/api/external/dryingOperation/getNotConfirmedList?orderId=${this.selectInfo.id}`)
					.then(res => {
						this.confirmedList = res.data.data
						this.isShowConfirmed = true
					})
					.catch(error => {
					})
		},

		/**
		 * 提交入库单确认
		 * @returns {Promise<ElMessageComponent>}
		 */
		async submitconfirmed(){
			if(this.submitconfirmedList == null || this.submitconfirmedList.length == 0){
				this.$message.error("请选择需要确认的数据!")
				return
			}
			let volume = 0
			this.submitconfirmedList.forEach(value => {
				if(value.volume != '' && value.volume != null){
					volume += parseInt(value.volume)
				}
			})
			let form = {
				remark : this.remark,
				confirmedList : this.submitconfirmedList,
				orderId:this.selectInfo.id,
				volume:volume,

			}
			const res = await this.$http.put(
					`/${this.$ServiceName}/api/external/dryingOperation/updateStatus`,
					form
			)
			if (res.status == 200) {
				if (res.data.success) {
					this.isShowConfirmed = false
					this.remark = ''
					this.submitconfirmedList = []
					this.searchData()
					return this.$message.success(res.data.msg)
				} else {
					return this.$message.error(res.data.msg)
				}
			} else {
				this.$message.error('操作失败！')
			}
		},
		// 时间转换函数
		formatTime(row, column) {
			let dtime = new Date(row)
			const year = dtime.getFullYear()
			let month = dtime.getMonth() + 1
			if (month < 10) {
				month = "0" + month
			}
			let day = dtime.getDate()
			if (day < 10) {
				day = "0" + day
			}
			let hour = dtime.getHours()
			if (hour < 10) {
				hour = "0" + hour
			}
			let minute = dtime.getMinutes()
			if (minute < 10) {
				minute = "0" + minute
			}
			let second = dtime.getSeconds()
			if (second < 10) {
				second = "0" + second
			}
			return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second
		},
		// 获取客户下拉框
		getCustomer() {
			publicapi.getlistCustomer().then(res => {
				this.cusList = res.data.data
			})
		},

		//获取字典树种
		getListTreeType() {
			publicapi.getDictData('TREETYPE').then(res => {
				this.cargoList = res.data.data.TREETYPE
			})
		},
		// 获取字典数据
		getDictData() {
			publicapi.getDictData("DEMAND,KILN_NO").then(res => {
				this.labourDemandList = res.data.data.DEMAND
				this.entryPlacingList = res.data.data.KILN_NO
			})
		},
		// 获取组织
		getCompanyList() {
			publicapi.getListComp().then(res => {
				this.companyList = res.data.data
			})
		},
		// 重置
		resetSearch() {
			this.searchForm = {
				rderNo: "",
				cargoCode: "",
				customerCode: "",
			}
		},
		// 分页查询
		sizeChange(val) {
			this.queryall.pagesize = val
			this.searchData()
		},
		// 分页查询
		pageChange(val) {
			this.queryall.startpage = val
			this.searchData()
		},
		// 查询主列表数据
		searchData() {
			this.loading = true
			this.prdAffirmList = []
			let params = Object.assign({}, this.queryall, this.searchForm)
			api.listPages(params).then(res => {
				this.loading = false
				this.tableData = res.data.data.pages
				this.queryall.startpage = res.data.data.pageNum // 当前页
				this.queryall.pagesize = res.data.data.pageSize // 每页多少
				this.queryall.totalNum = res.data.data.totalNum
				this.selectInfo = null
			})
		},
		// 选中主列表行数据
		getSelectRow(val) {
			console.log(val)
			this.selectInfo = val
			this.selectInfoCon = val
			this.getPrdAffirm()
			this.batchList = []
			this.orderItemIdList = []
			this.submitconfirmedList = []
			const arr = this.selectInfo.cargoInfoList
			if(arr !=null && arr.length !=0){
				arr.forEach(v =>{
					let param = {
						value:'',
						label:''
					}
					param.value =v.batch
					param.label =v.batch
					this.batchList.push(param)
					let orderItemParam = {
						value:'',
						label:''
					}
					orderItemParam.value =v.id
					orderItemParam.label =v.treeSpeciesName
					this.orderItemIdList.push(orderItemParam)
				})

			}
		},

		// 编辑按钮
		handleEdit(val) {
			this.zid = val.id
			this.isShow = true
			this.getTableDetailed()
		},

		//详情
		async handleDetailed(val) {
			await this.$http
				.get(`/${this.$ServiceName}/api/external/dryingOperation/getAffirmDetailed?id=${val.id}&settlementType=${this.settlementType}`)
				.then(res => {
					this.isShowDetailed = true
					this.handleDetailedList = res.data.data
				})
				.catch(error => {
				})

		},


		// 撤销
		handlerCancel(row) {
			if(row.status != '1'){
				this.$message.error("该数据已结算!")
				return
			}
			this.$confirm("确定撤销该确认单吗?", "提示", {
				confirmButtonText: "确定",
				cancelButtonText: "取消",
				type: "warning",
			}).then(() => {
						this.cancel(row.id)
					})
					.catch(() => {
						this.$message({
							type: "info",
							message: "已取消",
						})
					})
		},

		async cancel(id){
			const res = await this.$http.delete(
					`/${this.$ServiceName}/api/external/dryingOperation/dryingCancel?id=${id}`,
			)
			if (res.status == 200) {
				if (res.data.success) {
					this.searchData()
					return this.$message.success(res.data.msg)
				} else {
					return this.$message.error(res.data.msg)
				}
			}
		},

		// 添加货物信息
		addCargo() {
			let data = {
				id: "",
				cargoCode: "",
				cargoName: "",
				cargoLength: "",
				cargoWidth: "",
				cargoHeight: "",
				quantity: "",
				packages: "",
				volume: "",
				arrivalDate: "",
				waterContent: "",
				batch: "",
			}
			this.form.cargoInfoList.push(data)
		},
		// 删除选中给数据
		deleteCargoInfo(index) {
			this.form.cargoInfoList.splice(index, 1)
		},
		// 选中一行表格数据
		seletableclick(val) {
			console.log(val)
		},
		// 新增/编辑
		addUpdate() {
			if (this.form.id) {
				this.updateById()
			} else {
				this.insert()
			}
		},
		// 选中复选框
		checkChange(val) {
			console.log(val)
		},
		// 对货名赋值
		seleCargoName(index, value) {
			console.log(index)
			console.log(value)
			this.form.cargoInfoList[index].cargoName = this.cargoList.filter(v => v.cargoCode == value)[0].cargoName
		},
		// 新增
		insert() {
			let params = Object.assign({}, this.form)

			if (this.checkedDemand.length > 0) {
				params.demand = this.checkedDemand.join(",")
			}
			var quantity = 0,
				packages = 0,
				volume = 0
			this.form.cargoInfoList.forEach(v => {
				if (v.quantity) {
					quantity += Number(v.quantity)
				}
				if (v.packages) {
					packages += Number(v.packages)
				}
				if (v.volume) {
					volume += Number(v.volume)
				}
			})
			params.quantity = quantity
			params.packages = packages
			params.volume = volume

			api.insert(params).then(res => {
				this.$message.success("新增成功")
				this.isShow = false
				this.searchData()
			})
		},
		// 编辑
		updateById() {
			let params = Object.assign({}, this.form)

			if (this.checkedDemand.length > 0) {
				params.demand = this.checkedDemand.join(",")
			}

			var quantity = 0,
				packages = 0,
				volume = 0
			this.form.cargoInfoList.forEach(v => {
				if (v.quantity) {
					quantity += Number(v.quantity)
				}
				if (v.packages) {
					packages += Number(v.packages)
				}
				if (v.volume) {
					volume += Number(v.volume)
				}
			})
			params.quantity = quantity
			params.packages = packages
			params.volume = volume
			params.isAudit = this.isAudit
			api.updatebyid(params).then(res => {
				this.$message.success("更新成功")
				this.isShow = false
				this.searchData()
			})
		},
		// 更新状态
		auditStatus() {
			if (this.selectInfo == null) {
				return this.$message.info("请先选择一条数据")
			}
			let val = this.selectInfo
			this.form.id = val.id
			this.form.companyId = val.companyId
			this.form.companyName = val.companyName
			this.form.customerCode = val.customerCode
			this.form.customerName = val.customerName
			this.form.orderNo = val.orderNo
			this.form.contacts = val.contacts
			this.form.remark = val.remark
			this.form.contactNumber = val.contactNumber
			this.form.cargoInfoList = val.cargoInfoList
			if (val.demand) {
				this.checkedDemand = val.demand.split(",")
			}
			this.isAudit = "1"
			this.isShow = true
		},
		// 审核
		auditOrder() {
			let params = Object.assign({}, this.form)

			if (this.checkedDemand.length > 0) {
				params.demand = this.checkedDemand.join(",")
			}

			var quantity = 0,
				packages = 0,
				volume = 0
			this.form.cargoInfoList.forEach(v => {
				if (v.quantity) {
					quantity += Number(v.quantity)
				}
				if (v.packages) {
					packages += Number(v.packages)
				}
				if (v.volume) {
					volume += Number(v.volume)
				}
			})
			params.quantity = quantity
			params.packages = packages
			params.volume = volume
			params.isAudit = this.isAudit
			api.updatebyid(params).then(res => {
				this.$message.success("审核成功")
				this.isShow = false
				this.searchData()
			})
		},
		// 收货入库弹窗
		beLaidUping() {
			if (this.selectInfo == null) {
				return this.$message.info("请先选择一条数据")
			}
			if(this.selectInfo.status ==1){
				return this.$message.error("该数据未审核！！")
			}
			this.receiptFrom.receiptTableData = []
			let val = this.selectInfo
			this.form.id = val.id
			this.form.companyId = val.companyId
			this.form.companyName = val.companyName
			this.form.customerCode = val.customerCode
			this.form.customerName = val.customerName
			this.form.orderNo = val.orderNo
			this.form.contacts = val.contacts
			this.form.remark = val.remark
			this.form.contactNumber = val.contactNumber
			this.form.cargoInfoList = val.cargoInfoList
			if (val.demand) {
				this.checkedDemand = val.demand.split(",")
			}

			this.isReceiptShow = true
			this.receiptFrom.orderNo = val.orderNo
		},
		// 入窑弹窗
		kilnEntrying() {
			if (this.selectInfo == null) {
				this.$message.info("请选中一条数据！")
				return
			}
			if(this.selectInfo.status ==1){
				return this.$message.error("该数据未审核！！")
			}
			this.showType = true
			const params = {
				orderId: this.selectInfo.id,
			}
			dryingApi.getKilnEntryList(params).then(res => {
				console.log(res)
				if (res.data.code == "0000") {
					this.kilnEntryFrom.orderNo = this.selectInfo.orderNo
					this.kilEntryTableData = res.data.data
					this.kilEntryTableData.forEach(item => {
						item.workDate = this.formatTime(item.workDate).substring(0, 10)
					})
					this.kilnEntryFrom.quantity = this.kilEntryTableData.reduce((sum, e) => sum + Number(e.quantity), 0)
					this.kilnEntryFrom.volume = this.kilEntryTableData.reduce((sum, e) => sum + Number(e.volume), 0)
				}
			})
		},
		// 计算包数方数件数
		computeInfo() {
			this.quantity = this.receiptFrom.receiptTableData.reduce((sum, e) => sum + Number(e.quantity), 0)
			this.volume = this.receiptFrom.receiptTableData.reduce((sum, e) => sum + Number(e.volume), 0)
		},
		// 收货入库删除
		handleDelete(index, rows) {
			rows.splice(index, 1);
			this.packages = this.receiptFrom.receiptTableData.length
			this.quantity = this.receiptFrom.receiptTableData.reduce((sum, e) => sum + Number(e.quantity), 0)
			this.volume = this.receiptFrom.receiptTableData.reduce((sum, e) => sum + Number(e.volume), 0)
		},
		//复制
		handleDuplicate(row){
			let data = {
				index: this.receiptFrom.receiptTableData.length,
				productName: row.productName,
				packageNo: row.packageNo,
				quantity: row.quantity,
				volume: row.volume,
			}
			this.receiptFrom.receiptTableData.push(data)
			this.packages = this.receiptFrom.receiptTableData.length
			this.quantity = this.receiptFrom.receiptTableData.reduce((sum, e) => sum + Number(e.quantity), 0)
			this.volume = this.receiptFrom.receiptTableData.reduce((sum, e) => sum + Number(e.volume), 0)
		},
		// 收货入库行点击事件
		selectReceiptData(row) {},
		//收货入库添加行
		increaseRow() {
			let data = {
				index: this.receiptFrom.receiptTableData.length,
				productName: "",
				packageNo: "",
				quantity: "",
				volume: "",
			}
			this.receiptFrom.receiptTableData.push(data)
			this.packages = this.receiptFrom.receiptTableData.length
		},
		// 入库保存
		addReceiptUpdate() {
			this.$refs.receiptRulesRef.validate(valid => {
				if (valid) {
					const params = {
						orderId: this.selectInfo.id,
						orderNo: this.receiptFrom.orderNo,
						batch: this.receiptFrom.batch,
						orderItemId: this.receiptFrom.orderItemId,
						truckNo: this.receiptFrom.truckNo,
						workDate: this.formatTime(this.receiptFrom.workDate).substring(0, 10),
						quantity: this.quantity, //总件数，数据条数加起来
						packages: this.packages, //总包数，加起来
						volume: this.volume, //方数，加起来
						listTPrdDryWorkItem: this.receiptFrom.receiptTableData,
					}
					dryingApi
						.dryingInsert(params)
						.then(res => {
							console.log(res)
							if (res.data.code == "0000") {
								this.$message.success(res.data.msg)
								this.isReceiptShow = false
								this.receiptFrom.orderNo = ""
								this.receiptFrom.batch = ""
								this.receiptFrom.orderItemId = ""
								this.receiptFrom.truckNo = ""
								this.receiptFrom.workDate = ""
								this.quantity = 0
								this.packages = 0
								this.volume = 0
								this.receiptFrom.receiptTableData = []
							} else {
								this.$message.info(res.data.msg)
							}
						})
						.catch(err => {
							this.$message.error(err.response.data.msg)
							this.isReceiptShow = false
							this.receiptFrom.orderNo = ""
							this.receiptFrom.batch = ""
							this.receiptFrom.truckNo = ""
							this.receiptFrom.workDate = ""
							this.quantity = 0
							this.packages = 0
							this.volume = 0
							this.receiptFrom.receiptTableData = []
						})
				}
			})
		},
		// 入窑表格选中
		handleSelectionChange(rowList) {
			console.log(rowList, "+++++++")
			this.selectChangeRow = rowList
			if (rowList.length >= 2) {
				// 单个入窑
				this.entryKilnDisable = true
				this.batchKilnDisable = false
			} else {
				this.entryKilnDisable = false
				this.batchKilnDisable = false
			}
		},
		confirmedSelectionChange(rowList) {
			this.submitconfirmedList  = rowList
		},
		// 单个入窑表格选择
		handleKilnEntryChange(rowList) {
			console.log(rowList, "单个入窑表格选择")
			this.selectKilnEntryList = rowList
		},
		visibleChange(done) {
			this.$confirm("数据未保存,确认关闭？")
				.then(_ => {
					done()

					this.$refs.kilEntryChange.clearSelection()

					this.selectChangeRow = null
					this.entryKilnDisable = false
					this.batchKilnDisable = false
				})
				.catch(_ => {})
		},
		// 批量入窑弹窗
		batchPlacingClose(done) {
			this.batchEntryPlacingFrom = {
				quantity: "", //总根数
				packages: "", //总包数
				volume: "", //总方量
				workDate: "", //入窑日期
				isWet: "Y", //是否码板
				kilnCode: "", //窑号
				enterKilnNo: "", // 入窑编号
			}
			done()
		},
		entryPlacingClose(done) {
			this.entryPlacingFrom = {
				workDate: "", //入窑日期
				isWet: "Y", //isWet
				kilnCode: "", //窑代码
				kilnName: "", //窑号
				enterKilnNo: "", // 入窑编号
				truckNo: "", //车号
				// 入窑table
				entryPlacingTable: [],
			}
			done()
		},
		kilnDischargeColse(done) {
			this.kilnDischargeDialogFrom = {
				exitKilnDate: "", //出窑日期
				isDry: "Y", //是否抽条,Y是N否
				isSort: "N", //是否分选,Y是N否
				enterKilnNo: "", //入窑编号
				turnKilnNo: "", //转窑编号
				turnKilnDate: "", //转窑日期
				kilnCode: "", //窑代码（字典）
				kilnName: "", //窑号（字典）
				turnKilnCode: "", //转窑代码（字典）
				turnKilnName: "", //转窑号（字典）
			}
			done()
		},
		releaseDownClose(done) {
			this.releaseDownDialogFrom = {
				releaseDate: "",
				truckNo: "",
			}
			done()
		},
		visibleReceiptChange(done) {
			this.$confirm("数据未保存,确认关闭？")
				.then(_ => {
					done()
					this.receiptFrom = {
						orderNo: "", //订单编号
						batch: "", //批次
						truckNo: "", //车号
						workDate: "", //作业日期
						// 收货入库列表数据
						receiptTableData: [],
					}
					this.isReceiptShow = false
					this.quantity = 0
					this.packages = 0
					this.volume = 0
				})
				.catch(_ => {})
		},
		// 批量入窑按钮
		batchKilnChange() {
			if (this.selectChangeRow == null) {
				this.$message.info("请选中数据！")
				return
			}
			this.batchPlacingShowType = true
			this.batchEntryPlacingFrom.quantity = this.selectChangeRow.reduce((sum, e) => sum + Number(e.quantity), 0)
			this.batchEntryPlacingFrom.volume = this.selectChangeRow.reduce((sum, e) => sum + Number(e.volume), 0)
			this.batchEntryPlacingFrom.packages = this.selectChangeRow.reduce((sum, e) => sum + Number(e.packages), 0)
		},
		// 入窑
		entryKilnChange() {
			if (this.selectChangeRow == null) {
				this.$message.info("请选中数据！")
				return
			}
			this.entryPlacingShowType = true
			console.log(this.selectChangeRow)
			this.entryPlacingFrom.truckNo = this.selectChangeRow[0].truckNo
			this.entryPlacingFrom.workDate = this.selectChangeRow[0].workDate
			this.entryPlacingFrom.entryPlacingTable = this.selectChangeRow[0].listTPrdDryWorkItem
			// entryPlacingFrom.entryPlacingTable
		},
		// 批量 单个入窑保存
		storeInKilnEvent(type) {
			let params = []

			if (type == "kilnEntryOne") {
				this.$refs.entryPlacingRulesRef.validate(valid => {
					if (valid) {
						let handleList = this.selectKilnEntryList
						handleList.forEach(item => {
							this.$set(item, "enterKilnDate", this.formatTime(this.entryPlacingFrom.workDate).substring(0, 10)) //入窑日期
							this.$set(item, "isWet", this.entryPlacingFrom.isWet) //是否码板
							this.$set(item, "enterKilnNo", this.entryPlacingFrom.enterKilnNo) //入窑编号
							this.$set(item, "kilnCode", this.entryPlacingFrom.kilnCode) //窑代码
							this.entryPlacingList.forEach(items => {
								if (items.dictValue == item.kilnCode) {
									this.$set(item, "kilnName", items.dictLabel) //窑号
								}
							})
						})
						params = [
							{
								id: this.selectChangeRow[0].id,
								orderId: this.selectChangeRow[0].orderId,
								batch: this.selectChangeRow[0].batch,
								truckNo: this.selectChangeRow[0].truckNo,
								workDate: this.selectChangeRow[0].workDate,
								quantity: this.selectChangeRow[0].quantity, //总件数
								packages: this.selectChangeRow[0].packages, //总包数
								volume: this.selectChangeRow[0].volume, //方数
								listTPrdDryWorkItem: handleList,
							},
						]
						dryingApi
							.kilnEntry(params)
							.then(res => {
								console.log(res)
								if (res.data.code == "0000") {
									this.$message.success(res.data.msg)
									this.entryPlacingShowType = false

									this.kilnEntrying()
									this.computeInfo()
									this.emptyType()
								} else {
									this.$message.warning(res.data.msg)
								}
							})
							.catch(err => {
								this.$message.error(err.response.data.msg)
							})
					}
				})
			} else {
				this.$refs.batchPlacingRulesRef.validate(valid => {
					if (valid) {
						let handleListBacth = this.selectChangeRow

						handleListBacth.forEach(item => {
							item.listTPrdDryWorkItem.forEach(childItem => {
								this.$set(childItem, "enterKilnDate", this.formatTime(this.batchEntryPlacingFrom.workDate).substring(0, 10)) //入窑日期
								this.$set(childItem, "isWet", this.batchEntryPlacingFrom.isWet) //是否码板
								this.$set(childItem, "enterKilnNo", this.batchEntryPlacingFrom.enterKilnNo) //入窑编号
								this.$set(childItem, "kilnCode", this.batchEntryPlacingFrom.kilnCode) //窑代码
								this.entryPlacingList.forEach(items => {
									if (items.dictValue == childItem.kilnCode) {
										this.$set(childItem, "kilnName", items.dictLabel) //窑号
									}
								})
							})
						})
						params = handleListBacth
						dryingApi
							.kilnEntry(params)
							.then(res => {
								console.log(res)
								if (res.data.code == "0000") {
									this.$message.success(res.data.msg)
									this.batchPlacingShowType = false

									this.kilnEntrying()
									this.computeInfo()
									this.emptyType()
								} else {
									this.$message.warning(res.data.msg)
								}
							})
							.catch(err => {
								this.$message.error(err.response.data.msg)
							})
					}
				})
			}
			console.log(params)
		},
		emptyType() {
			this.entryPlacingFrom = {
				workDate: "", //入窑日期
				isWet: "Y", //isWet
				kilnCode: "", //窑代码
				kilnName: "", //窑号
				enterKilnNo: "", // 入窑编号
				truckNo: "", //车号
				// 入窑table
				entryPlacingTable: [],
			}
			this.batchEntryPlacingFrom = {
				quantity: "", //总根数
				packages: "", //总包数
				volume: "", //总方量
				workDate: "", //入窑日期
				isWet: "Y", //是否码板
				kilnCode: "", //窑号
				enterKilnNo: "", // 入窑编号
			}
			this.selectKilnEntryList = []
			this.selectChangeRow = null
			this.$refs.kilnEntryOneRef.clearSelection()
			this.$refs.kilEntryChange.clearSelection()
		},
		// 出窑弹窗
		kilnDischarge() {
			if (this.selectInfo == null) {
				this.$message.info("请选中一条数据！")
				return
			}
			if(this.selectInfo.status ==1){
				return this.$message.error("该数据未审核！！")
			}
			this.iskilnDischargeShow = true
			this.kilnDischargeFrom.orderNo = this.selectInfo.orderNo
			this.queryKilnChange()
		},
		//出窑查询
		queryKilnChange() {
			const params = {
				orderNo: this.kilnDischargeFrom.orderNo,
				enterKilnNo: this.kilnDischargeFrom.enterKilnNo,
			}
			dryingApi
				.getKilnDischargeList(params)
				.then(res => {
					console.log(res)
					if (res.data.code == "0000") {
						this.kilnDischargeTableData = res.data.data
						this.kilnDischargeTableData.forEach(item => {
							item.enterKilnDate = this.formatTime(item.enterKilnDate).substring(0, 10)
						})
						this.kilnDischargeFrom.quantity = this.kilnDischargeTableData.reduce((sum, e) => sum + Number(e.quantity), 0)

						this.kilnDischargeFrom.volume = this.kilnDischargeTableData.reduce((sum, e) => sum + Number(e.volume), 0)
					}
				})
				.catch(err => {
					console.log(err)
					this.$message.error(err.response.data.msg)
				})
		},
		// 出窑表格选中
		handleKilnDisChange(row) {
			this.kilnDischargeSelectList = row
			console.log(this.kilnDischargeSelectList)
		},
		// 出窑 转窑打开弹窗
		kilnDischargeHandle(type) {
			if (this.kilnDischargeSelectList == null) {
				this.$message.info("请选中数据！")
				return
			}
			this.kilnStatus = type
			this.kilnDischargeVisible = true
		},
		visibleDischarge(done) {
			this.$confirm("数据未保存,确认关闭？")
				.then(_ => {
					done()
					this.kilnDischargeSelectList = null
					this.$refs.kilnDischargeTable.clearSelection()
					this.kilnDischargeDialogFrom = {
						exitKilnDate: "", //出窑日期
						isDry: "Y", //是否抽条,Y是N否
						isSort: "Y", //是否分选,Y是N否
						enterKilnNo: "", //入窑编号
						turnKilnNo: "", //转窑编号
						turnKilnDate: "", //转窑日期
						kilnCode: "", //窑代码（字典）
						kilnName: "", //窑号（字典）
						turnKilnCode: "", //转窑代码（字典）
						turnKilnName: "", //转窑号（字典）
					}
				})
				.catch(_ => {})
		},
		// 出窑 转窑保存
		kilnRotaryHandle(type) {
			this.$refs.kilnDischargeRef.validate(valid => {
				if (valid) {
					let params = []
					if (type === "0") {
						// 出窑保存
						this.kilnDischargeSelectList.forEach(item => {
							let requestInfo = {
								id: item.id,
								exitKilnDate: this.formatTime(this.kilnDischargeDialogFrom.exitKilnDate).substring(0, 10),
								isDay: this.kilnDischargeDialogFrom.isDry,
								isSort: this.kilnDischargeDialogFrom.isSort,
							}
							params.push(requestInfo)
						})

						dryingApi
							.kilnDischarge(params)
							.then(res => {
								console.log(res)
								if (res.data.code == "0000") {
									this.$message.success(res.data.msg)
									this.queryKilnChange()
								} else {
									this.$message.warning(res.data.msg)
								}
							})
							.catch(err => {
								// console.log(err);
								this.$message.error(err.response.data.msg)
							})
					} else if (type === "1") {
						// 转窑保存
						this.entryPlacingList.forEach(item => {
							if (item.dictValue == this.kilnDischargeDialogFrom.turnKilnCode) {
								this.kilnDischargeDialogFrom.turnKilnName = item.dictLabel
							}
						})

						this.kilnDischargeSelectList.forEach(item => {
							let requestInfo = {
								id: item.id,
								turnKilnDate: this.formatTime(this.kilnDischargeDialogFrom.turnKilnDate).substring(0, 10),
								turnKilnNo: this.kilnDischargeDialogFrom.turnKilnNo,
								turnKilnCode: this.kilnDischargeDialogFrom.turnKilnCode,
								turnKilnName: this.kilnDischargeDialogFrom.turnKilnName,
							}
							params.push(requestInfo)
						})

						dryingApi
							.rotaryKiln(params)
							.then(res => {
								console.log(res)
								if (res.data.code == "0000") {
									this.$message.success(res.data.msg)
									this.queryKilnChange()
								} else {
									this.$message.warning(res.data.msg)
								}
							})
							.catch(err => {
								// console.log(err);
								this.$message.error(err.response.data.msg)
							})
					}
					this.kilnDischargeVisible = false

					this.$refs.kilnDischargeTable.clearSelection()
					this.kilnDischargeSelectList = null
					this.kilnDischargeDialogFrom = {
						exitKilnDate: "", //出窑日期
						isDry: "Y", //是否抽条,Y是N否
						isSort: "Y", //是否分选,Y是N否
						enterKilnNo: "", //入窑编号
						turnKilnNo: "", //转窑编号
						turnKilnDate: "", //转窑日期
						kilnCode: "", //窑代码（字典）
						kilnName: "", //窑号（字典）
						turnKilnCode: "", //转窑代码（字典）
						turnKilnName: "", //转窑号（字典）
					}
				}
			})
		},
		// 放货管理按钮
		releaseDowning() {
			if (this.selectInfo == null) {
				this.$message.info("请选中一条数据！")
				return
			}
			if(this.selectInfo.status ==1){
				return this.$message.error("该数据未审核！！")
			}
			this.isReleaseDownShow = true
			this.releaseDownFrom.orderNo = this.selectInfo.orderNo
			this.queryReleaseDown()
		},
		// 查询按钮
		queryReleaseDown() {
			const params = {
				orderNo: this.releaseDownFrom.orderNo,
				status: this.releaseDownFrom.status,
			}
			dryingApi
				.getReleaseList(params)
				.then(res => {
					if (res.data.code == "0000") {
						this.releaseDownTableData = res.data.data
						this.releaseDownTableData.forEach(item => {
							item.exitKilnDate = this.formatTime(item.exitKilnDate)
							item.releaseDate = this.formatTime(item.releaseDate)
						})
						this.releaseDownSelectList = null
						this.$refs.releaseDownTable.clearSelection()
					}
				})
				.catch(err => {
					this.$message.error(err.response.data.msg)
				})
		},
		// 选择数据
		handleReleaseDown(row) {
			this.releaseDownSelectList = row
		},
		// 放货按钮
		deliveryHandle() {
			if (this.releaseDownSelectList == null) {
				this.$message.info("请选中数据！")
				return
			}
			console.log(this.releaseDownSelectList.findIndex(items => items.status == "4"))
			if (this.releaseDownSelectList.findIndex(items => items.status == "4") == -1) {
				this.dialogReleaseDown = true
			} else {
				this.releaseDownSelectList.forEach(item => {
					if (item.status == "4") {
						let message =
							"订单号为：" +
							item.orderNo +
							"品名为：" +
							item.productName +
							"," +
							"包号为：" +
							item.packageNo +
							"," +
							"批次为：" +
							item.batch
						setTimeout(() => {
							this.$message.info(`选择数据中` + message + `是已放货数据`)
						}, 500)
					}
				})
				return
			}
		},
		// 弹窗关闭确定
		visibleReleaseDown(done) {
			this.$confirm("数据未保存,确认关闭？")
				.then(_ => {
					done()
					this.releaseDownSelectList = null
					this.$refs.releaseDownTable.clearSelection()
					this.releaseDownDialogFrom = {}
					this.releaseDownFrom.status = "3"
				})
				.catch(_ => {})
		},
		// 放货保存
		releaseDownDetermine() {
			this.$refs.releaseDownDialogRef.validate(valid => {
				if (valid) {
					let params = {
						orderId: this.selectInfo.id,
						orderNo: this.selectInfo.orderNo,
						customerId: this.selectInfo.customerId,
						customerName: this.selectInfo.customerName,
						companyName:this.selectInfo.companyName,
						companyId:this.selectInfo.companyId,
						truckNo: this.releaseDownDialogFrom.truckNo, //输入得车号
						workDate: this.formatTime(this.releaseDownDialogFrom.releaseDate).substring(0, 10), //这个就是放货日期
						quantity: this.releaseDownSelectList.reduce((sum, e) => sum + Number(e.quantity), 0), //总件数，数据条数加起来
						packages: this.releaseDownSelectList.length, //总包数，加起来
						volume: this.releaseDownSelectList.reduce((sum, e) => sum + Number(e.volume), 0), //方数，加起来
						listTPrdDryWorkItem: [],
					}
					this.releaseDownSelectList.forEach(item => {
						let days = new Date(this.formatTime(this.releaseDownDialogFrom.releaseDate).substring(0, 10)) - new Date(this.formatTime(item.exitKilnDate).substring(0, 10))
						params.listTPrdDryWorkItem.push({
							id: item.id,
							releaseDate: this.formatTime(this.releaseDownDialogFrom.releaseDate).substring(0, 10),
							days:days /  (1000 * 60 * 60 * 24),
							volume : item.volume
						})
					})
					console.log(params)
					dryingApi
						.release(params)
						.then(res => {
							if (res.data.code == "0000") {
								this.$message.success(res.data.msg)
								this.dialogReleaseDown = false
								this.releaseDownSelectList = null
								this.$refs.releaseDownTable.clearSelection()
								this.releaseDownDialogFrom = {
									releaseDate: "",
									truckNo: "",
								}
								this.queryReleaseDown()
							} else {
								this.$message.warning(res.data.msg)
							}
						})
						.catch(err => {
							this.$message.error(err.response.data.msg)
						})
				}
			})
		},
	},
}
</script>
<style lang="less" scoped>
@import "../../../assets/searchfrom.less";
/deep/ .receiptFrom {
	display: flex;
	justify-content: space-between;
	padding-right: 0px !important;
}
/deep/.el-form-item__label {
	width: auto !important;
	min-width: 80px !important;
	text-align: center !important;
}
/deep/.kilnEntryFrom {
	display: flex;
	justify-content: space-evenly;
	padding-right: 0px !important;
}
/deep/.kilnDischarge {
	display: flex;
	justify-content: space-around;
	padding-right: 0px !important;
}

/deep/ .el-drawer__header {
	margin-bottom: 0px;
	padding: 16px;
	border-bottom: 1px solid gainsboro;
}
/deep/ .el-form-item {
	padding-right: 20px;
	.el-select {
		width: 100%;
	}
}
.titleclass {
	background-color: rgb(247, 246, 246);
	height: 50px;
	width: 103%;
	margin-top: -10px;
	margin-left: -10px;
	line-height: 50px;
}
.titleclass2 {
	background-color: rgb(247, 246, 246);
	height: 50px;
	width: 103%;
	margin-left: -10px;
	line-height: 50px;
}
/deep/ .el-drawer__body {
	overflow-y: auto;
	margin-bottom: 50px;
}
/deep/ .demo-drawer__footer {
	text-align: right;
	padding-right: 1rem;
	border-top: 1px solid #c8cfde;
	background-color: #f5f7fa;
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	line-height: 50px;
	z-index: 20;
}
/deep/.receiptTableTitle {
	display: flex;
	background: #e6f7ff;
	justify-content: space-between;
	.receiptTableTitle-total {
		height: 50px;
		padding-left: 20px;

		line-height: 50px;
		width: 95%;
	}
	.receiptTableTitle-btn {
		width: 5%;
		height: 50px;
		padding: 0px 10px;
		line-height: 50px;
	}
}
/deep/.receiptTable {
	.el-form-item {
		margin-bottom: 5px;
		margin-top: 5px;
	}
	/deep/.el-table__body {
		margin-bottom: 10px;
	}
}
/deep/.kilEntryTableBox {
	background: #e6f7ff;
	.kilEntryTitle {
		height: 50px;
		line-height: 50px;
		.kilEntryTitle-total {
			padding: 0 15px;
		}
	}
}
/deep/.kilnDischargeTableBox {
	background: #e6f7ff;
	.kilnDischargeTitle {
		height: 50px;
		line-height: 50px;
		.kilnDischargeTitle-total {
			padding: 0 15px;
		}
	}
}
/deep/.entryPlacingTable {
	.el-form-item {
		margin-bottom: 5px;
		margin-top: 5px;
	}
	/deep/.el-table__body {
		margin-bottom: 10px;
	}
}
/deep/.entryPlacingFrom {
	justify-content: flex-start;
}
</style>